﻿package view
{
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.sh.game.util.*;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.text.*;
    import morn.core.components.*;
    import pluginfw.*;
    import view.message.*;

    public class AnnounceView extends Sprite
    {
        private var tipsArr:Array;
        private var _text1:TextField;
        private var _text2:TextField;
        private var _box1:Sprite;
        private var _box2:Sprite;
        private var isshowing1:Boolean = false;
        private var isshowing2:Boolean = true;
        private static const BGW:int = 680;

        public function AnnounceView()
        {
            this.tipsArr = [];
            this.mouseChildren = false;
            this.mouseEnabled = false;
            this._box1 = new Sprite();
            this.addChild(this._box1);
            this._box2 = new Sprite();
            this.addChild(this._box2);
            var _loc_1:* = new Image("png.common.s9_notive");
            _loc_1.sizeGrid = "10,10,10,10";
            _loc_1.width = BGW;
            _loc_1.height = 26;
            this._box1.addChild(_loc_1);
            this._text1 = new TextField();
            this._text1.autoSize = TextFieldAutoSize.LEFT;
            this._text1.wordWrap = false;
            this._text1.multiline = false;
            this._text1.defaultTextFormat = new TextFormat("宋体", 15, 16763904, null, null, null, null, null, TextFormatAlign.LEFT);
            this._text1.filters = [new GlowFilter(0, 1, 2, 2, 5)];
            this._text1.y = 3;
            this._box1.addChild(this._text1);
            this._box1.scrollRect = new Rectangle(0, 0, BGW, 35);
            this._text2 = new TextField();
            this._text2.autoSize = TextFieldAutoSize.LEFT;
            this._text2.wordWrap = false;
            this._text2.multiline = false;
            this._text2.defaultTextFormat = new TextFormat("宋体", 15, 16763904, null, null, null, null, null, TextFormatAlign.LEFT);
            this._text2.filters = [new GlowFilter(0, 1, 2, 2, 5)];
            this._box2.addChild(this._text2);
            this._box2.scrollRect = new Rectangle(0, 0, BGW, 35);
            this._box1.visible = false;
            this._box2.visible = false;
            this.visible = false;
            return;
        }// end function

        protected function enterFrameHandler(event:Event) : void
        {
            if (this.tipsArr.length > 0)
            {
            }
            return;
        }// end function

        private function checkShow() : void
        {
            if (this.tipsArr.length > 0)
            {
                if (this.isshowing1 == false)
                {
                    this.show1();
                }
            }
            return;
        }// end function

        public function showtxt(param1:Object) : void
        {
            var _loc_10:String = null;
            var _loc_2:* = param1 as Array;
            if (_loc_2 == null || _loc_2.length == 0)
            {
                return;
            }
            var _loc_3:* = _loc_2.pop();
            var _loc_4:* = ConfigDictionary.data.announce[_loc_3];
            if (ConfigDictionary.data.announce[_loc_3] == null)
            {
                Alert2.show("公告表没更新清理缓存" + _loc_3, "", ["确定", "取消"]);
                return;
            }
            var _loc_5:* = _loc_4.text;
            var _loc_6:* = _loc_4.color;
            var _loc_7:Array = [];
            if (_loc_6)
            {
                _loc_7 = _loc_6.split("#");
            }
            if (!_loc_5 || _loc_5 == "")
            {
                return;
            }
            var _loc_8:int = 0;
            while (_loc_8 < _loc_2.length)
            {
                
                _loc_10 = "ffcc00";
                if (_loc_7.length > _loc_8)
                {
                    _loc_10 = _loc_7[_loc_8];
                }
                _loc_2[_loc_8] = Html.covert("{" + _loc_10 + "#" + _loc_2[_loc_8] + "}");
                _loc_8++;
            }
            var _loc_9:* = "<font size=\'16\'>" + StringUtil.substitute(_loc_5, _loc_2) + "</font>";
            this.tipsArr.push(_loc_9);
            if (this.tipsArr.length > 50)
            {
                this.tipsArr.shift();
            }
            this.checkShow();
            return;
        }// end function

        public function showtxt2(param1:String) : void
        {
            if (!param1 || param1 == "")
            {
                return;
            }
            this.tipsArr.push(param1);
            if (this.tipsArr.length > 50)
            {
                this.tipsArr.shift();
            }
            this.checkShow();
            return;
        }// end function

        private function show1() : void
        {
            this.visible = true;
            this._box1.visible = true;
            this._text1.htmlText = this.tipsArr.shift();
            this._text1.x = BGW;
            var _loc_1:* = this._text1.textWidth;
            this.isshowing1 = true;
            TweenLite.to(this._text1, 20 * (_loc_1 + BGW) / 1000, {x:-_loc_1, onComplete:this.stopview1, ease:Linear.easeNone});
            return;
        }// end function

        private function stopview1() : void
        {
            this.isshowing1 = false;
            this._box1.visible = false;
            this.checkShow();
            return;
        }// end function

        private function show2() : void
        {
            this.visible = true;
            this._box2.visible = true;
            this._text2.htmlText = this.tipsArr.shift();
            this._text2.x = BGW;
            var _loc_1:* = this._text2.textWidth;
            TweenLite.to(this._text2, 50 * (_loc_1 + BGW) / 1000, {x:-(_loc_1 + BGW), onComplete:this.onComplete2});
            this.isshowing2 = true;
            return;
        }// end function

        private function onComplete2() : void
        {
            this.stopview2();
            return;
        }// end function

        private function stopview2() : void
        {
            this.isshowing2 = false;
            this._box2.visible = false;
            this.checkShow();
            return;
        }// end function

    }
}
